#include <stdio.h>

int main(int argc, char *argv[])
{

    int a = 0, b = 0, max = 0;
    scanf("%d %d", &a, &b);
    int c = a > b ? a : b;
    for (size_t i = 1; i <= c; i++)
    {
        if (a % i == 0 && b % i == 0)
        {
            if (max < i)
            {
                max = i;
            }
        }
    }

    printf("%d", max);

    return 0;
}